<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/11/28 0028
 * Time: 下午 7:17
 */
namespace app\api\controller;

use app\common\BaseHelper;
use app\common\validate\UserSubmitExamine;
use app\admin\service\Meeting as MeetingService;
use app\admin\model\User as UserMdl;
use app\admin\model\Letter as LetterMdl;
use app\admin\model\Joinmeeting;
use app\admin\model\Meeting;
use app\admin\model\Classroomresults;
use app\admin\model\Classhour;
use app\admin\model\Joinclassroom;
use app\admin\model\Image;
use app\admin\model\Joinexam;
use app\admin\model\Activity as ActivityMdl;
use think\Db;
use think\Exception;
use think\Request;

class User extends BaseController{

    //小程序端登录
    public function login(Request $request){
        if($request->isPost()){
            $param = $request->param();
            if(empty($param['username']) || empty($param['password'])){
                return show(config('status.ERROR_STATUS'),'用户名或密码错误','用户名或密码错误');
            }
            if($param['logintype'] != 1 && $param['logintype'] != 2){
                return show(config('status.ERROR_STATUS'),'参数不合法','参数不合法');
            }
            if($param['logintype'] == 1){
                //工作人员登录
                $where = [
                    'username' => $param['username'],
                    'status' => 1,
                    'type' => 1
                ];
            }else{
                //信访用户登录
                $where = [
                    'username' => $param['username'],
                    'status' => 1,
                    'type' => 2
                ];
            }
            $User = \app\admin\model\User::where($where)->find();
            if($User){
                $inputpwd = BaseHelper::passwordEncrypt($param['password']);
                if($inputpwd == $User->password){
                    //登录成功
                    return show(config('status.SUCCESS_STATUS'),'ok',$User);
                }else{
                    return show(config('status.ERROR_STATUS'),'用户名或密码错误','用户名或密码错误');
                }
            }else{
                return show(config('status.ERROR_STATUS'),'用户名或密码错误','用户名或密码错误');
            }
        }else{
            return show(config('status.ERROR_STATUS'),'非法请求','非法请求');
        }
    }

    /**
     * 注册
     */
    public function register()
    {
        $param = self::getHttpParam();
        (new UserSubmitExamine())->goCheck();

        if (empty($param->phone)) {
            return show(config('status.ERROR_STATUS'), self::NOT_PARAM, 'phone 不能为空');
        }
        if (empty($param->password)) {
            return show(config('status.ERROR_STATUS'), self::NOT_PARAM, 'password 不能为空');
        }
        Db::startTrans();
        $model = new UserMdl();

        $where = [
            'username' =>$param->phone
        ];
        $sql = $model->where($where)->find();
        if ($sql){
            return show(config('status.ERROR_STATUS'), '手机号重复注册', '手机号重复注册');
        }
        try {
            $data = [
                'id' => BaseHelper::getUUID(),
                'type' => 2,
                'sex' => $param->sex,
                'createDate' => date('Y-m-d H:i:s',time()),
                'p_name' => $param->name,
                'identityNumber' => $param->id_num,
                'p_phone' => $param->phone,
                'province' =>$param->area[0],
                'city'  => $param->area[1],
                'county' => $param->area[2],
                'address' => $param->address,
                'username' => $param->phone,
                'password' => BaseHelper::passwordEncrypt($param->password),
            ];
            $result = $model->save($data);

            if ($result !== false) {
                Db::commit();
                return show(config('status.SUCCESS_STATUS'), '注册成功', '注册成功');
            } else {
                Db::rollback();
                return show(config('status.ERROR_STATUS'), '注册失败', $model->getError());
            }
        } catch (Exception $e) {
            return show(config('status.ERROR_STATUS'), $e->getMessage(), $e->getMessage());
        }
    }

    /*
     *
     * */

    //获取用户信息
    public function getUserInfo(Request $request){
        $param = $request->param();
        if(empty($param['id'])){
            return show(config('status.ERROR_STATUS'),'缺少用户id参数','缺少用户id参数');
        }
        $User = \app\admin\model\User::get($param['id']);
        if($User){
            return show(config('status.SUCCESS_STATUS'),'ok',$User);
        }else{
            return show(config('status.ERROR_STATUS'),'',null);
        }
    }

    /*
     * 信访中心
     * */
    public function myLetter()
    {
        $param = self::getHttpParam();
        $start = 0;
        $length = 10;
        if (empty($param->userId)){
            return show(config('status.ERROR_STATUS'),self::NOT_PARAM,'userId不能为空');
        }
        if (empty($param->type)){
            return show(config('status.ERROR_STATUS'),self::NOT_PARAM,'type不能为空');
        }
        if (!empty($param->start)){
            $start = $param->start;
        }
        if (!empty($param->length)){
            $length = $param->length;
        }
        $where = [
            'user_id' => $param->userId,
            'status'    => $param->type
        ];
        $model = new LetterMdl();
        $result = $model->where($where)->limit($start,$length)->select();
        $total = count($result);
        if ($result){
            return showTotal(config('status.SUCCESS_STATUS'), self::MSG_SUCCESS, $result, $total);
        }
        return show(config('status.ERROR_STATUS'),self::NOT_DATA,'暂无数据');
    }

    /*
     * 我的反馈
     * */
    public function myFeedback()
    {
        $param = self::getHttpParam();
        $start = 0;
        $length = 10;
        if (!empty($param->start)){
            $start = $param->start;
        }
        if (!empty($param->length)){
            $length = $param->length;
        }
        if (empty($param->userId)){
            return show(config('status.ERROR_STATUS'),self::NOT_PARAM,'userId 不能为空');
        }
        $where = [
            'user_id' => $param->userId
        ];
        $model = new LetterMdl();
        $result = $model->where($where)->limit($start,$length)->select();
        $total = count($result);
        if ($result){
            return showTotal(config('status.SUCCESS_STATUS'), self::MSG_SUCCESS, $result, $total);
        }
        return show(config('status.ERROR_STATUS'),self::NOT_DATA,'暂无数据');
    }

    /*
     * 我的学习计划
     * */
    public function myClassRoom()
    {
        $param = self::getHttpParam();
        if (empty($param->userId)){
            return show(config('status.ERROR_STATUS'),self::NOT_PARAM,'userId不能为空');
        }
        $model = new joinclassroom();
        $where = [
            'a.loginId' => $param->userId
        ];
        $fields = "a.progress, a.status,m.title , m.imgUrl ,m.id as classId ";
        $result = $model->alias('a')
            ->where($where)
            ->field($fields)
            ->join('microclassroom m','a.classId = m.id')
            ->select();
            foreach($result as &$v)
            {
                /*
                $model = new Classhour();
                $where = [
                    'classId' => $v['classId']
                ];
                $classhour = $model->where($where)->field('id')->select(); //所有章节id
                $v['classhour'] = count($classhour);
                $model = new Classroomresults();
                $where = [
                    'joinId' => $v['classId'],
                    'loginId'     => $param->userId
                ];
                $number = count($model->where($where)->select());
                $progress = round($number / $v['classhour'] ,2) * 100 . '%';
                $model = new joinclassroom();
                $where = [
                    'loginId' => $param->userId,
                    'classId' => $v['classId']
                ];
                if ($progress == '100%'){
                    $data = [
                        'progress' => $progress,
                        'status'   => 1
                    ];
                    $model->where($where)->update($data,true);

                }else{
                    $data = [
                        'progress' => $progress,
                        'status'   => 0
                    ];

                    $model->where($where)->update($data,true);
                }
                */
            }

            $model = new joinclassroom();
            if ($param->status == 1){
                $where = [
                    'a.loginId' => $param->userId,
                    'a.status'  => 1
                ];
                $fields = "a.progress, a.status,m.title , m.imgUrl ,m.id as classId ";
                $result = $model->alias('a')
                    ->where($where)
                    ->field($fields)
                    ->join('microclassroom m','a.classId = m.id')
                    ->select();

            }elseif($param->status == 0){
                $where = [
                    'a.loginId' => $param->userId,
                    'a.status'  => 0
                ];
                $fields = "a.progress, a.status,m.title , m.imgUrl ,m.id as classId ";
                $result = $model->alias('a')
                    ->where($where)
                    ->field($fields)
                    ->join('microclassroom m','a.classId = m.id')
                    ->select();
            }
            foreach($result as $v)
            {
                $model = new Classhour();
                $where = [
                    'classId' => $v['classId']
                ];
                $classhour = $model->where($where)->field('id')->select(); //所有章节id
                $v['classhour'] = count($classhour);
            }

            return show(config('status.SUCCESS_STATUS'),self::MSG_SUCCESS,$result);


    }

    /*
     * 我的会议进程
     * */
    public function myMeeting()
    {
        $param = self::getHttpParam();
        if (empty($param->userId)){
            return show(config('status.ERROR_STATUS'),self::NOT_PARAM,'userId不能为空');
        }
        //我参与的会议
        $date = date('Y-m-d',time());
        if (!empty($param->date)){
            $date = $param->date;
        }
        $model = new joinmeeting();
        $where = [
            'a.memberId' => $param->userId,
            'm.status'   => 1,
            'm.startTime' => ['like', $date.'%']
        ];
        if (!empty($param->title)){
            $where['m.title'] = ['like', '%'.$param->title.'%'];
        }
        $fields = " a.isSign , a.isNotarize ,m.id as meetingId, m.startTime, m.endTime ,m.title ,m.address";
        $result = $model->alias('a')
            ->where($where)
            ->field($fields)
            ->join('party_meeting m','a.meetingId = m.id','left')
            ->select();
        foreach($result as $v)
        {
            $v['date'] = substr($v['startTime'],0,10);
            $v['startTime'] = substr($v['startTime'],11);
            $v['endTime'] = substr($v['endTime'],11);
        }
        $data['myJoinMeeting'] = $result;

        //我创建的会议

        if (!empty($param->date)){
            $date = $param->date;
        }

        $where = [
            'createOper' => $param->userId,
            'status'   => 1,
            'startTime' => ['like', $date.'%']
        ];
        if (!empty($param->title)){
            $where['title'] = ['like', '%'.$param->title.'%'];
        }

        $item = \app\admin\model\Meeting::where($where)->select();

        foreach($item as $v)
        {
            $v['date'] = substr($v['startTime'],0,10);
            $v['startTime'] = substr($v['startTime'],11);
            $v['endTime'] = substr($v['endTime'],11);
        }
        $data['myCreateMeeting'] = $item;

        if ($data){
            return show(config('status.SUCCESS_STATUS'),self::MSG_SUCCESS,$data);
        }
        return show(config('status.ERROR_STATUS'),self::NOT_DATA,'暂无数据');
    }

    /*
     * 编辑/新增会议
     * */
    public function saveMeeting(Request $request)
    {
        $param = self::getHttpParam();
        if (empty($param->userId)){
            return show(config('status.ERROR_STATUS'),self::NOT_PARAM,'userId不能为空');
        }
        if (empty($param->ids)){
            return show(config('status.ERROR_STATUS'),self::NOT_PARAM,'参会人不能为空');
        }
        if (empty($param->title)){
            return show(config('status.ERROR_STATUS'),self::NOT_PARAM,'标题不能为空');
        }
        if (empty($param->address)){
            return show(config('status.ERROR_STATUS'),self::NOT_PARAM,'活动地点不能为空');
        }

        if (!empty($param->meetingId)){
            //修改
            $data = (array)$param;
            $data['updateDate'] = date('Y-m-d H:i:s',time());
            $data['updateOper'] = $data['userId'];
            $data['id']         = $data['meetingId'];
            $data['status']     = 1;
            $where = [
                'createOper' => $data['userId'],
                'id'         => $data['meetingId']
            ];
            //删除之前的参会人
            $delMember = \app\admin\model\Joinmeeting::where(['meetingId' => $data['meetingId']])->delete();
            $result = \app\admin\model\Meeting::update($data,$where,true);
            $data['ids'] = str_replace('"','',$data['ids']);
            $data['ids'] = str_replace('[','',$data['ids']);
            $data['ids'] = str_replace(']','',$data['ids']);
            $data['ids'] = explode (',',$data['ids']);
            foreach($data['ids'] as $v)
            {
                $info['id'] = BaseHelper::getUUID();
                $info['memberId'] = $v;
                $info['meetingId'] = $data['meetingId'];
                $info['isSign'] = 2;
                $info['isNotarize'] = 2;
                $where = [
                    'memberId' =>  $v,
                    'meetingId' => $data['meetingId']
                ];
                //查询是否已报名
                $member = \app\admin\model\Joinmeeting::where($where)->find();
                if (!$member){
                    \app\admin\model\Joinmeeting::create($info,true);
                }
            }

            if (!$result){
                return show(config('status.ERROR_STATUS'),self::NOT_DATA,'编辑失败');
            }
            return show(config('status.SUCCESS_STATUS'),self::MSG_SUCCESS,'编辑成功');


        }else{
            //新增
            $data = (array)$param;
            $data['id'] = BaseHelper::getUUID();
            $data['createDate'] = date('Y-m-d H:i:s',time());
            $data['createOper'] = $data['userId'];
            $data['status'] = 1;
            $data['signCode'] = MeetingService::createMeetingCode($data['id'], $tenantId='');
            $result = \app\admin\model\Meeting::create($data,true);

            foreach($data['ids'] as $v)
            {
                $info['id'] = BaseHelper::getUUID();
                $info['memberId'] = $v;
                $info['meetingId'] = $data['id'];
                $info['isSign'] = 2;
                $info['isNotarize'] = 2;
                $result = \app\admin\model\Joinmeeting::create($info,true);
            }

            if (!$result){
                return show(config('status.ERROR_STATUS'),self::NOT_DATA,'添加失败');
            }
            return show(config('status.SUCCESS_STATUS'),self::MSG_SUCCESS,'添加成功');
        }
    }

    /*
     * 删除会议
     * */
    public function delMeeting()
    {
        $param = self::getHttpParam();
        if (empty($param->userId)){
            return show(config('status.ERROER_STATUS'),self::NOT_PARAM,'userId不能为空');
        }
        if (empty($param->meetingId)){
            return show(config('status.ERROER_STATUS'),self::NOT_PARAM,'meetingId不能为空');
        }
        //删除会议
        $where = [
            'createOper'    => $param->userId,
            'id'            => $param->meetingId
        ];
        $meeting = \app\admin\model\Meeting::find($where);
        if (!$meeting){
            return show(config('status.ERROER_STATUS'),self::NOT_PARAM,'无法删除他人创建的会议');
        }
        $result = \app\admin\model\Meeting::destroy($where);
        if (!$result){
            return show(config('status.ERROER_STATUS'),self::NOT_PARAM,'删除失败');
        }
        $member = \app\admin\model\Joinmeeting::destroy(['meetingId' => $param->meetingId]);
        if (!$member){
            return show(config('status.ERROER_STATUS'),self::NOT_PARAM,'删除人员失败');
        }
        return show(config('status.SUCCESS_STATUS'),self::MSG_SUCCESS,'删除成功');
    }

    /*
     * 添加参会人
     * */
    /*public function addJoinmeeting()
    {
        $param = self::getHttpParam();
        if (empty($param->userId)){
            return show(config('status.ERROER_STATUS'),self::NOT_PARAM,'userId不能为空');
        }
        if (empty($param->meetingId)){
            return show(config('status.ERROER_STATUS'),self::NOT_PARAM,'meetingId不能为空');
        }
        foreach($param->ids as $v)
        {
            $data['id'] = BaseHelper::getUUID();
            $data['memberId'] = $v->userId;
            $data['meetingId'] = $v->meetingId;
            $data['isSign'] = 2;
            $data['isNotarize'] = 2;
            $result = \app\admin\model\Joinmeeting::create($data,true);
        }

        if (!$result){
            return show(config('status.ERROR_STATUS'),self::NOT_DATA,'添加失败');
        }
        return show(config('status.SUCCESS_STATUS'),self::MSG_SUCCESS,'添加成功');
    }*/

    /*
     * 删除参会人
     * */
    /*public function delJoinmeeting()
    {
        $param = self::getHttpParam();
        if (empty($param->userId)){
            return show(config('status.ERROER_STATUS'),self::NOT_PARAM,'userId不能为空');
        }
        if (empty($param->meetingId)){
            return show(config('status.ERROER_STATUS'),self::NOT_PARAM,'meetingId不能为空');
        }
        $where =[
            'meetingId' => $param->meetingId,
            'memberId'  => $param->userId
        ];
        $result = \app\admin\model\Joinmeeting::destroy($where);
        if (!$result){
            return show(config('status.ERROR_STATUS'),self::NOT_DATA,'删除失败');
        }
        return show(config('status.SUCCESS_STATUS'),self::MSG_SUCCESS,'删除成功');
    }*/

    //修改信访用户资料
    public function modifyVisit(Request $request){
        if($request->isPost()){
            $param = $request->param();
            if(empty($param['id'])){
                return show(config('status.ERROR_STATUS'),'参数错误','参数错误');
            }
            $User = \app\admin\model\User::get($param['id']);
            if($User){
                if($User->status == 1 && $User->type == 2){
                    $User->p_name = $param['nickname'];
                    $User->p_phone = $param['phone'];
                    $User->sex = $param['sex'];
                    $User->identityNumber = $param['id_num'];
                    $User->province = $param['area'][0];
                    $User->city = $param['area'][1];
                    $User->county = $param['area'][2];
                    $User->address = $param['address'];
                    if(isset($param['p_imgUrl']) && !empty($param['p_imgUrl'])){
                        $User->p_imgUrl = $param['p_imgUrl'];
                    }
                    $User->save();
                    return show(config('status.SUCCESS_STATUS'), 'ok', 'ok');
                }else{
                    return show(config('status.ERROR_STATUS'),'用户状态异常','用户状态异常');
                }
            }else{
                return show(config('status.ERROR_STATUS'),'用户不存在','用户不存在常');
            }
        }else{
            return show(config('status.ERROR_STATUS'),'非法请求','非法请求');
        }
    }

    //修改用户密码
    public function modifyPassword(Request $request){
        if($request->isPost()){
            $param = $request->param();
            if(empty($param['id']) || empty($param['password'])){
                return show(config('status.ERROR_STATUS'),'参数错误','参数错误');
            }
            if($param['remark3'] != $param['repassword']){
                return show(config('status.ERROR_STATUS'),'参数错误','参数错误');
            }
            if($param['tag'] != 0 && $param['tag'] != 1){
                return show(config('status.ERROR_STATUS'),'参数错误','参数错误');
            }
            $User = \app\admin\model\User::get($param['id']);

            if($User){
                if($User->status == 1){
                    if($param['tag'] == 1){
                        //信访用户
                        if($User->type != 2){
                            return show(config('status.ERROR_STATUS'),'用户状态异常','用户状态异常');
                        }
                    }else{
                        //员工
                        if($User->type != 1){
                            return show(config('status.ERROR_STATUS'),'用户状态异常','用户状态异常');
                        }
                    }
                    if($User->password == BaseHelper::passwordEncrypt($param['password'])){
                        $repassword = BaseHelper::passwordEncrypt($param['repassword']);
                        $User->password = $repassword;
                        $User->save();
                        return show(config('status.SUCCESS_STATUS'), 'ok', 'ok');
                    }else{
                        return show(config('status.ERROR_STATUS'),'原密码错误','原密码错误');
                    }
                }else{
                    return show(config('status.ERROR_STATUS'),'用户状态异常','用户状态异常');
                }

            }else{
                return show(config('status.ERROR_STATUS'),'用户不存在','用户不存在常');
            }
        }else{
            return show(config('status.ERROR_STATUS'),'非法请求','非法请求');
        }
    }

    //修改工作人员资料
    public function updateUserInfo(Request $request){
        if($request->isPost()){
            $param = $request->param();
            if(empty($param['xtCurrentUserId'])){
                return show(config('status.ERROR_STATUS'),'参数错误','参数错误');
            }
            $User = \app\admin\model\User::get($param['xtCurrentUserId']);
            if($User->status == 1 && ($User->type == 1 || $User->type == 0)){
                $User->p_name = $param['nickname'];
                $User->p_phone = $param['phone'];
                $User->sex = $param['userExtendEO']['sex'];
                $User->education = $param['userExtendEO']['education'];
                $User->duties = $param['userExtendEO']['position'];
                if(isset($param['headimg']) && !empty($param['headimg'])){
                    $User->p_imgUrl =  $param['headimg'];
                }
                $User->save();
                return show(config('status.SUCCESS_STATUS'), 'ok', 'ok');
            }else{
                return show(config('status.ERROR_STATUS'),'用户状态异常','用户状态异常');
            }
        }else{
            return show(config('status.ERROR_STATUS'),'非法请求','非法请求');
        }
    }

    /*
     * 获取我的考试
     * */
    public function getMyOnlineexams()
    {
        $param = self::getHttpParam();

        $start = 0;
        $length = 20;
        if (empty($param->loginId)) {
            return show(config('status.ERROR_STATUS'), self::NOT_PARAM, 'loginId 不能为空');
        }
        if (!empty($param->start)) {
            $start = $param->start;
        }
        if (!empty($param->length)) {
            $length = $param->length;
        }

        $userId = $param->loginId;
        $where = [
            'a.userId' => $userId,
            'e.isDelete' => 2
        ];


        $fields = 'a.id as joinId, a.score, e.id as examId, e.name, e.startTime, e.endTime, e.passingGrade, e.isDelete';
        $result = Joinexam::alias('a')->where($where)->join('party_exam_answer e', 'a.examId = e.id')->limit($start, $length)->field($fields)->select();
        $total = Joinexam::alias('a')->where($where)->join('party_exam_answer e', 'a.examId = e.id')->count();

        if (empty($result)) {
            return show(config('status.ERROR_STATUS'), self::NOT_DATA, '未查到考试');
        }

        foreach ($result as &$item) {
            $joinExams = Joinexam::where(['examId' => $item['examId']])->count();
            // 参与人数
            $item['joinExams'] = $joinExams;
        }

        return showTotal(config('status.SUCCESS_STATUS'), self::MSG_SUCCESS, $result, $total);
    }

    /*
     * 我的活动
     * */
    public function myActivity()
    {

        $param = self::getHttpParam();
        $start = 0;
        $length = 20;


        if (!empty($param->start)) {
            $start = $param->start;
        }
        if (!empty($param->length)) {
            $length = $param->length;
        }


        $where = [
            'isDelete' => 2,
            'p.userId' => $param->userId
        ];

        $model = new ActivityMdl();
        $fields = 'a.id as activityId, a.title, a.imgUrl, a.deadline , a.endTime';
        $result = $model->alias('a')
            ->where($where)
            ->join('party_activity_users p','a.id = p.activityId')
            ->limit($start, $length)
            ->field($fields)
            ->select();

        $total = count($result);

        if (empty($result)) {
            return show(config('status.ERROR_STATUS'), self::NOT_DATA, '未查到活动');
        }

        foreach ($result as &$item) {
            // 参与人数
            $Joinactivitys = \app\admin\model\Joinactivity::where(['activityId' => $item['activityId']])->count();
            $item['Joinactivity'] = $Joinactivitys;
        }

        return showTotal(config('status.SUCCESS_STATUS'), self::MSG_SUCCESS, $result, $total);
    }

    /*
     * 文件中心
     * */
    public function myLibrary()
    {
        $param = self::getHttpParam();
        $start = 0;
        $length = 10;
        if (!empty($param->start)) {
            $start = $param->start;
        }
        if (!empty($param->length)) {
            $length = $param->length;
        }

        if (empty($param->userId)){
            return show(config('status.ERROR_STATUS'),self::NOT_PARAM,'userId 不能为空');
        }

        $libraryMdl = new \app\admin\model\Library();
        $ids = [];
        // 所有人公开
        $allOpenIds = $libraryMdl->where(['openType' => 0])->field('id')->select();
        $allOpenIds = array_column($allOpenIds, 'id');
        // 部分人公开
        $openIds = \app\admin\model\Libraryopen::alias('a')->where(['a.userId' => $param->userId, 'b.openType' => 1])->join('library b', 'a.libraryId = b.id')->field('a.libraryId')->select();
        $openIds = array_column($openIds, 'libraryId');
        // 上传者
        $uploadIds = $libraryMdl->where(['openType' => 2, 'createOper' => $param->userId])->field('id')->select();
        $uploadIds = array_column($uploadIds, 'id');
        $ids = array_merge($allOpenIds, $openIds, $uploadIds);
        // 去重
        $ids = array_unique($ids);
        $where = [
            'a.id' => ['in', $ids]
        ];
        $fields = 'a.id, a.createDate, a.name, a.fileUrl, a.fileType, u.p_name, u.p_imgUrl';
        $result = \app\admin\model\Library::alias('a')
            ->where($where)
            ->join('user u' ,'a.createOper = u.id')
            ->field($fields)
            ->order('a.createDate')
            ->limit($start, $length)
            ->select();
        $total = count($result);
        foreach($result as &$v)
        {
            $file_name = str_replace('http://img.1miaodao.cn/','',$v['fileUrl']);

            $file_type = substr($v['fileUrl'],strripos($v['fileUrl'],'.')+1);
            $v['file_name'] = $file_name;
            $v['file_type'] = $file_type;
        }
        if ($result){
            return showTotal(config('status.SUCCESS_STATUS'),self::MSG_SUCCESS,$result,$total);
        }
    }
}